package com.stars.empoly.adapter

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.google.gson.Gson
import com.qmuiteam.qmui.kotlin.onClick
import com.stars.empoly.R
import com.stars.empoly.activity.*
import com.stars.empoly.config.MIntentAction
import com.stars.empoly.databinding.ItemCouponBinding
import com.stars.empoly.databinding.ItemMsgBinding
import com.stars.empoly.model.CouponsBean
import com.stars.empoly.model.TrMsgList
import com.stars.empoly.vmodel.MsgVModel
import com.trailer.base.base.BAdapter
import com.trailer.base.utils.B
import com.trailer.base.utils.UiSwitch

class CouponAdapter(var type: String?) : BAdapter<CouponsBean, BaseDataBindingHolder<ItemCouponBinding>>(R.layout.item_coupon) {

    override fun convert(holder: BaseDataBindingHolder<ItemCouponBinding>, item: CouponsBean) {
        holder.dataBinding?.item = item
        holder.dataBinding?.position = holder.adapterPosition


        holder.dataBinding?.ll?.onClick {

            if(type=="1"){

                val intent = Intent()
                var bundle= Bundle()
                bundle.putString("bean",Gson().toJson(item))
                intent.putExtras(bundle)
                var con=context() as Activity
                con.setResult(Activity.RESULT_OK, intent)
                con.finish()

            }

        }

    }
}
